package co.yixiang.modules.shop.web.controller;

import co.yixiang.modules.shop.entity.YxSalesManage;
import co.yixiang.modules.shop.service.YxSalesManageService;
import co.yixiang.modules.shop.web.param.YxSalesManageQueryParam;
import co.yixiang.modules.shop.web.vo.YxSalesManageQueryVo;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.common.api.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import co.yixiang.common.web.vo.Paging;
import co.yixiang.common.web.param.IdParam;

/**
 * <p>
 * 主管业务员表 前端控制器
 * </p>
 *
 * @author hisen
 * @since 2020-07-31
 */
@Slf4j
@RestController
@RequestMapping("/yxSalesManage")
@Api("主管业务员表 API")
public class YxSalesManageController extends BaseController {

    @Autowired
    private YxSalesManageService yxSalesManageService;

    /**
    * 添加主管业务员表
    */
    @PostMapping("/add")
    @ApiOperation(value = "添加YxSalesManage对象",notes = "添加主管业务员表",response = ApiResult.class)
    public ApiResult<Boolean> addYxSalesManage(@Valid @RequestBody YxSalesManage yxSalesManage) throws Exception{
        boolean flag = yxSalesManageService.save(yxSalesManage);
        return ApiResult.result(flag);
    }

    /**
    * 修改主管业务员表
    */
    @PostMapping("/update")
    @ApiOperation(value = "修改YxSalesManage对象",notes = "修改主管业务员表",response = ApiResult.class)
    public ApiResult<Boolean> updateYxSalesManage(@Valid @RequestBody YxSalesManage yxSalesManage) throws Exception{
        boolean flag = yxSalesManageService.updateById(yxSalesManage);
        return ApiResult.result(flag);
    }

    /**
    * 删除主管业务员表
    */
    @PostMapping("/delete")
    @ApiOperation(value = "删除YxSalesManage对象",notes = "删除主管业务员表",response = ApiResult.class)
    public ApiResult<Boolean> deleteYxSalesManage(@Valid @RequestBody IdParam idParam) throws Exception{
        boolean flag = yxSalesManageService.removeById(idParam.getId());
        return ApiResult.result(flag);
    }

    /**
    * 获取主管业务员表
    */
    @PostMapping("/info")
    @ApiOperation(value = "获取YxSalesManage对象详情",notes = "查看主管业务员表",response = YxSalesManageQueryVo.class)
    public ApiResult<YxSalesManageQueryVo> getYxSalesManage(@Valid @RequestBody IdParam idParam) throws Exception{
        YxSalesManageQueryVo yxSalesManageQueryVo = yxSalesManageService.getYxSalesManageById(idParam.getId());
        return ApiResult.ok(yxSalesManageQueryVo);
    }

    /**
     * 主管业务员表分页列表
     */
    @PostMapping("/getPageList")
    @ApiOperation(value = "获取YxSalesManage分页列表",notes = "主管业务员表分页列表",response = YxSalesManageQueryVo.class)
    public ApiResult<Paging<YxSalesManageQueryVo>> getYxSalesManagePageList(@Valid @RequestBody(required = false) YxSalesManageQueryParam yxSalesManageQueryParam) throws Exception{
        Paging<YxSalesManageQueryVo> paging = yxSalesManageService.getYxSalesManagePageList(yxSalesManageQueryParam);
        return ApiResult.ok(paging);
    }

}

